]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/bin: Use class handlers for ::child-{added,removed}
authorZander Brown <zbrown@gnome.org>
Thu, 9 Nov 2023 15:45:29 +0000 (15:45 +0000)
committerZander Brown <zbrown@gnome.org>
Tue, 14 Nov 2023 11:10:53 +0000 (11:10 +0000)
Now these signals are directly on ClutterActor, we can use class handlers
instead

Note we don't make the same change to StScrollView as it would clash
with the internal children.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3014>

src/st/st-bin.c

index 750192f2365971b151c4f8b9daad14424cbd0c7d..a10510821f3a83e0e0a8559079665506be6391d0 100644 (file)
@@ -176,6 +176,47 @@ st_bin_get_preferred_height (ClutterActor *self,
   st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
 }
 
+static void
+set_child (StBin *bin, ClutterActor *child)
+{
+  StBinPrivate *priv = st_bin_get_instance_private (bin);
+
+  if (!g_set_weak_pointer (&priv->child, child))
+    return;
+
+  clutter_actor_queue_relayout (CLUTTER_ACTOR (bin));
+
+  g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_CHILD]);
+}
+
+static void
+st_bin_child_added (ClutterActor *container,
+                    ClutterActor *actor)
+{
+  StBin *bin = ST_BIN (container);
+  StBinPrivate *priv = st_bin_get_instance_private (bin);
+
+  if (priv->child)
+    g_warning ("Attempting to add an actor of type %s to "
+               "an StBin, but the bin already contains a %s. "
+               "Was add_child() used repeatedly?",
+               G_OBJECT_TYPE_NAME (actor),
+               G_OBJECT_TYPE_NAME (priv->child));
+
+  set_child (ST_BIN (container), actor);
+}
+
+static void
+st_bin_child_removed (ClutterActor *container,
+                      ClutterActor *actor)
+{
+  StBin *bin = ST_BIN (container);
+  StBinPrivate *priv = st_bin_get_instance_private (bin);
+
+  if (priv->child == actor)
+    set_child (bin, NULL);
+}
+
 static void
 st_bin_popup_menu (StWidget *widget)
 {
@@ -266,6 +307,8 @@ st_bin_class_init (StBinClass *klass)
   actor_class->get_preferred_width = st_bin_get_preferred_width;
   actor_class->get_preferred_height = st_bin_get_preferred_height;
   actor_class->allocate = st_bin_allocate;
+  actor_class->child_added = st_bin_child_added;
+  actor_class->child_removed = st_bin_child_removed;
 
   widget_class->popup_menu = st_bin_popup_menu;
   widget_class->navigate_focus = st_bin_navigate_focus;
@@ -285,52 +328,9 @@ st_bin_class_init (StBinClass *klass)
   g_object_class_install_properties (gobject_class, N_PROPS, props);
 }
 
-static void
-set_child (StBin *bin, ClutterActor *child)
-{
-  StBinPrivate *priv = st_bin_get_instance_private (bin);
-
-  if (!g_set_weak_pointer (&priv->child, child))
-    return;
-
-  clutter_actor_queue_relayout (CLUTTER_ACTOR (bin));
-
-  g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_CHILD]);
-}
-
-static void
-actor_added (ClutterActor *container,
-             ClutterActor *actor)
-{
-  StBin *bin = ST_BIN (container);
-  StBinPrivate *priv = st_bin_get_instance_private (bin);
-
-  if (priv->child)
-    g_warning ("Attempting to add an actor of type %s to "
-               "an StBin, but the bin already contains a %s. "
-               "Was add_child() used repeatedly?",
-               G_OBJECT_TYPE_NAME (actor),
-               G_OBJECT_TYPE_NAME (priv->child));
-
-  set_child (ST_BIN (container), actor);
-}
-
-static void
-actor_removed (ClutterActor *container,
-               ClutterActor *actor)
-{
-  StBin *bin = ST_BIN (container);
-  StBinPrivate *priv = st_bin_get_instance_private (bin);
-
-  if (priv->child == actor)
-    set_child (bin, NULL);
-}
-
 static void
 st_bin_init (StBin *bin)
 {
-  g_signal_connect (bin, "actor-added", G_CALLBACK (actor_added), NULL);
-  g_signal_connect (bin, "actor-removed", G_CALLBACK (actor_removed), NULL);
 }
 
 /**